package com.qfs.server.util.gserver;

import java.io.InputStreamReader;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class QQUtil {
	public static String encodeQQPassword(String password, String usalt,
			String code) {
		ScriptEngineManager m = new ScriptEngineManager();
		ScriptEngine se = m.getEngineByName("javascript");
		Object t = "";
		try {
			se.eval(new InputStreamReader(QQUtil.class.getResourceAsStream("/gserver/login.js")
					));
			t = se.eval("$.Encryption.getEncryption(\"" + password + "\", \""
					+ usalt + "\", \"" + code + "\");");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return (t.toString());
	}
}
